<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>驴妈妈统计系统</title>
<meta name="description" content="overview &amp; stats" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<!-- bootstrap & fontawesome -->
<link rel="stylesheet" href="${request.contextPath}/static/assets/css/bootstrap.min.css" />
<link rel="stylesheet" href="${request.contextPath}/static/assets/css/bootstrap.css" />
<link rel="stylesheet"
	href="${request.contextPath}/static/assets/font-awesome/4.5.0/css/font-awesome.min.css" />
<!-- page specific plugin styles -->
<link rel="stylesheet" href="${request.contextPath}/static/assets/css/jquery.gritter.min.css" />
<!-- text fonts -->
<link rel="stylesheet" href="${request.contextPath}/static/assets/css/fonts.googleapis.com.css" />
<!-- ace styles -->
<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace.min.css"
	class="ace-main-stylesheet" id="main-ace-style" />
<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace-skins.min.css" />
<link rel="stylesheet" href="${request.contextPath}/static/assets/css/ace-rtl.min.css" />
<link rel="stylesheet" href="${request.contextPath}/static/stylesheets/daterangepicker.css">
<script src="${request.contextPath}/assets/js/jquery-2.1.4.min.js"></script>
<!-- ace settings handler -->
<script src="${request.contextPath}/static/assets/js/ace-extra.min.js"></script>
</head>

<body class="no-skin" style="background-color: #FFF;">
	<div class="page-content" style="padding: 2px 2px 0px;">
		<div class="tabbable">
			<div class="tab-content">
			 	<div id="manage" class="tab-pane active in">
			 	<!-- 筛选条件开始 -->
				<div class="row">
					<div class="col-sm-12">
						<div class="widget-box">
							<div class="widget-body" style="background-color: #EFF3F8;">
								<div class="widget-main">
									<form class="form-inline" id="searchForm" method="post"
										action="${request.contextPath}/backConfig/configList">
										<input type="hidden" id="_csrf" name="${_csrf.parameterName}"
											value="${_csrf.token}" />
										<!-- 框架原因，所有post请求必须加这行代码 -->
										<div class="form-group">
												<label for="exampleInputName2">系统代码 
												<input class="form-control"
													name="syscodeVO" placeholder="系统代码" type="text" value="${configListConditionVO.syscodeVO!}" style="width:120px">
												</label>
												<label for="exampleInputName" style="margin-left: 30px;">配置名称 
												<input class="form-control"
						                            name="confignameVO" placeholder="配置名称" type="text" value="${configListConditionVO.confignameVO!}" style="width:120px">
												</label>
												<button type="submit" class="btn btn-pink btn-sm"
													id="search" style="margin-left: 30px;">
													<span
														class="ace-icon fa fa-search icon-on-right bigger-110"></span>
													查询
												</button>
										       <a class="green" role="button" data-target="#myModal" data-toggle="modal" style="margin-left: 30px;">
													<button type="submit" class="btn btn-pink btn-sm"
														id="search" onclick="addNewConfig()">
														<span class="ace-icon fa icon-on-right bigger-110"></span>
														新增
													</button>
												</a>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- 筛选条件结束 -->
				<!-- tab开始 -->
				<div class="row">
					 <div class="col-sm-12">
						<div class=" widget-box" style="border:none;">
								<table id="dynamic-table"
									class="table table-striped table-bordered table-hover dataTable no-footer"
									role="grid" aria-describedby="dynamic-table_info">
									<thead>
										<tr>
											<th>系统代码</th>
											<th>配置名称</th>
											<th>配置描述</th>
											<th>参数名称</th>
											<th>参数值</th>
											<th>参数值描述</th>
											<th>配置是否有效</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody>
										<#if configVOList?? && configVOList?size&gt;0> <#list
										configVOList as configVO>
										<tr class="">
											<td>${configVO.syscode!}</td>
											<td>${configVO.configname!}</td>
											<td>${configVO.configdesc!}</td>
											<td>${configVO.paramname!}</td>
											<td><#if configVO.paramvalue?? && configVO.paramvalue?length&gt;20>
						                        ${configVO.paramvalue?substring(0,20)}....<a onclick="showDetailConfig('${configVO.configid}')"><i class="ace-icon fa fa-eye"></i></a> 
						                        <#else>
						                        ${configVO.paramvalue!} </#if>
											</td>
											<td>${configVO.valuedesc!}</td>
											<td>
											<#if configVO.available =="1">
											 有效
											<#else>
											无效
											</#if> 
											</td>
											<td>
												<div class="hidden-sm hidden-xs action-buttons"
													align="right">
													<a class="green" onclick="updateConfig('${configVO.syscode!}','${configVO.configname!}','${configVO.paramname!}','${configVO.valueseq!}','${configVO.available!}')"
														role="button"> <i
														class="ace-icon fa fa-pencil bigger-130"></i>
													</a>
<!-- 												    <a class="red" href="${request.contextPath}/backConfig/configDelete?syscode=${configVO.syscode!}
													&configname=${configVO.configname!}&paramname=${configVO.paramname!}
													&valueseq=${configVO.valueseq!}&available=${configVO.available!} ">
													  <i class="ace-icon fa fa-trash-o bigger-130" onClick="return confirm('确定删除?');"></i>
													</a> -->
													
										 	        <a class="red" onclick = "deleteConfig('${configVO.syscode!}','${configVO.configname!}','${configVO.paramname!}','${configVO.valueseq!}','${configVO.available!}')">
													<i class="ace-icon fa fa-trash-o bigger-130"></i>
													</a>
													
												</div>
											</td>
										</tr>
										</#list> <#else>
										<tr>
											<td colspan="12">
												<div class="alert alert-danger" style="margin-bottom: 0px;"
													role="alert">没有记录!</div>
											</td>
										</tr>
										</#if>

									</tbody>
								</table>
                                 <#include "/paginator.html">
							</div>
						</div>
					</div>
					<!-- tab结束-->
				</div>
				<div class="row">
					<div class="col-xs-12">
						<button class="btn btn-info" data-toggle="modal" type="button"
							style="display: none;" id="update" data-target="#myModal">
						</button>
							<div class="modal fade" id="myModal02" tabindex="-1" role="dialog"
								aria-labelledby="myModalLabel" aria-hidden="true">
								<div class="modal-dialog">
									<div class="modal-content" style="width:800px; height:300px">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal"
												aria-hidden="true">×</button>
											<h4 class="modal-title" id="myModalLabel"><strong>参数值</strong></h4>
										</div>
										<div class="modal-body" id="paramvalueDetail">
										</div>
									</div>
									<!-- /.modal-content -->
								</div>
								<!-- /.modal -->
							</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<button class="btn btn-info" data-toggle="modal" type="button"
							style="display: none;" id="update" data-target="#myModal">
						</button>
						<form id="updateCode" class="form-horizontal" role="form"
							action="${request.contextPath}/backConfig/configAdd">
							<input type="hidden" id="_csrf" name="${_csrf.parameterName}"
											value="${_csrf.token}" />
							<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
								aria-labelledby="myModalLabel" aria-hidden="true">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal"
												aria-hidden="true">×</button>
											<h4 class="modal-title" id="myModalLabel">基础配置</h4>
										</div>
										<div class="modal-body">
											<input id="configid" name="configid" value="" type="hidden">

											<div class="space-4"></div>
											<div class="form-group">
												<div class="col-sm-9">
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1"> 系统代码 </label>

														<div class="col-sm-9">
															<input type="text" id="syscode" name="syscode"
																placeholder="系统代码" class="form-control" required="required" readonly>
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1"> 配置名称 </label>

														<div class="col-sm-9">
															<input type="text" id="configname" name="configname"
																placeholder="配置名称" class="form-control" required="required" readonly>
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1"> 配置描述</label>

														<div class="col-sm-9">
															<input type="text" id="configdesc" name="configdesc"
																placeholder="配置描述" class="form-control" readonly>
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1"> 参数名称 </label>

														<div class="col-sm-9">
															<input type="text" id="paramname" name="paramname"
																placeholder="参数名称" class="form-control" required="required" readonly>
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1"> 参数值序列 </label>

														<div class="col-sm-9">
															<input type="text" id="valueseq" placeholder="参数值序列"
																class="form-control" required="required" readonly>
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1"> 参数值 </label>

														<div class="col-sm-9">
															<input type="text" id="paramvalue" name="paramvalue"
																placeholder="参数值" class="form-control">
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1"> 参数值描述 </label>

														<div class="col-sm-9">
															<input type="text" id="valuedesc" name="valuedesc"
																placeholder="参数值描述" class="form-control">
														</div>
													</div>
													<div class="form-group">
														<label class="col-sm-3 control-label no-padding-right"
															for="form-field-1"> 是否有效 </label>

														<div class="col-sm-9">
														 <select name="available" id="available" aria-controls="dynamic-table" class="form-control input-sm">
															    <option  value="1" >有效</option>
															    <option  value="0" >无效</option>  
														  </select>
														</div>
													</div>

												</div>
											</div>
										</div>
										<div class="modal-footer">
											<button type="button" class="btn btn-pink btn-sm"
												data-dismiss="modal">关闭</button>
											<button type="submit" class="btn btn-pink btn-sm" id="save">
												提交</button>
										</div>
									</div>
									<!-- /.modal-content -->
								</div>
								<!-- /.modal -->
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<input type="hidden" id="configlistcontext" value="${request.contextPath}"/>
	<script src="${request.contextPath}/static/assets/js/bootstrap.min.js"></script>

	<!-- page specific plugin scripts -->
	<script src="${request.contextPath}/static/assets/js/jquery-ui.min.js"></script>
	<script src="${request.contextPath}/static/assets/js/jquery.ui.touch-punch.min.js"></script>
	<script src="${request.contextPath}/static/assets/js/jquery.gritter.min.js"></script>
	<!-- ace scripts -->
	<script src="${request.contextPath}/static/assets/js/ace-elements.min.js"></script>
	<script src="${request.contextPath}/static/assets/js/ace.min.js"></script>
	<script src="${request.contextPath}/static/assets/js/bootbox.js"></script>
	<!-- user scripts -->
	<script src="${request.contextPath}/static/assets/js/user/base.js"></script>

	<script type="text/javascript" src="${request.contextPath}/static/javascripts/moment.js"></script>
	<script type="text/javascript" src="${request.contextPath}/static/javascripts/daterangepicker.js"></script>

	<script type="text/javascript">
	var configlistcontext = $("#configlistcontext").val();
	   function addNewConfig(){
   
		   $('#myModal').find("input").val("");
		   $('#myModal').find("input").removeAttr("readOnly");
		   $('#myModal').find("select").removeAttr("readOnly");
	   }
	
	   function updateConfig(syscode,configname,paramname,valueseq,available){
 		   $.ajax({
				url : configlistcontext+'/backConfig/configEdit?syscode='+syscode+'&configname='+configname+'&paramname='+paramname+'&valueseq='+valueseq+'&available='+available,
				type : "GET",
				success:function(data) {
					console.log(data)
					if(data.sessionStatus==540){//异步请求session过期状态
						window.location.href=configlistcontext+"/login";
						//location.href="show_product?prodId="+prod_id+"&sceneryName="+tdSceneryName+"&pageNum="+$("#pageNum").val();
					}else if(data.code=1){
						var configVO = data.configVO;
						$("#myModal").modal("show");
						$('#syscode').val(configVO.syscode);
						$('#configname').val(configVO.configname);
						$('#configdesc').val(configVO.configdesc);
						$('#paramname').val(configVO.paramname);
						$('#valueseq').val(configVO.valueseq);
						$('#paramvalue').val(configVO.paramvalue);
						$('#valuedesc').val(configVO.valuedesc);
						$('#available').find("option[value="+configVO.available+"]").attr("selected",true);
						$('#configid').val(configVO.configid);
						$('#syscode').attr({ readonly: 'true' }); 
						$('#configname').attr({ readonly: 'true' }); 
						$('#paramname').attr({ readonly: 'true' }); 
						$('#valueseq').attr({ readonly: 'true' }); 
						$('#paramvalue').attr({ readonly: 'true' }); 
					}
				}
			  }); 
		 
		  
	   }
	   
	   function showDetailConfig(id){
		   $.ajax({
				url : configlistcontext+'/backConfig/configEdit?configid='+id,
				type : "GET",
				success:function(data) {
					console.log(data);
					if(data.sessionStatus==540){//异步请求session过期状态
						window.location.href=configlistcontext+"/login";
						//location.href="show_product?prodId="+prod_id+"&sceneryName="+tdSceneryName+"&pageNum="+$("#pageNum").val();
					}else if(data.code=1){
						var configVO = data.configVO;
						$("#myModal02").modal("show");
						$("#paramvalueDetail").html(configVO.paramvalue);
					}
				}
			  }); 
		 
	   }
	   
	   
	   
	   function deleteConfig(syscode,configname,paramname,valueseq,available){
		   bootbox.confirm("<strong style='font-size:15px;padding-left:200px'>确认删除该条数据吗？</strong>", function(result){
		   if(result){
		   $.ajax({
				url : configlistcontext+'/backConfig/configDelete?syscode='+syscode+'&configname='+configname+'&paramname='+paramname+'&valueseq='+valueseq+'&available='+available,
				type : "GET",
				success:function(data) {
					console.log(data);
					if(data.sessionStatus==540){//异步请求session过期状态
						window.location.href=configlistcontext+"/login";
					}else if(data.code=="0"){
						bootbox.alert("<strong style='font-size:15px;padding-left:200px'>数据删除失败！</strong>", function(){window.location.reload() ; });
					}else{
						bootbox.alert("<strong style='font-size:15px;padding-left:200px'>数据删除成功！</strong>", function(){window.location.reload() ; });
					}
					
				}
			  }); 
			}
		}); 
	  }

	   
	   
	   
</script>


</body>
</html>